﻿using MainFrame.Repository.Migrations;
using MainFrame.Repository.Model;
using Qianke.Common.EntityFramework;
using SQLite.CodeFirst;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace MainFrame.Repository
{
    [DbConfigurationType(typeof(MyConfiguration))]
    public class MFContext: DbContext
    {
        /// <summary>
        /// 任务信息
        /// </summary>
        public DbSet<TaskInfo> TaskInfo { set; get; }

        public MFContext() : base("mfdb")
        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //base.OnModelCreating(modelBuilder);
            ////modelBuilder.Entity<OrderInfo>().Property(p => p.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
          

            //var CurrentAssmbly = Assembly.GetExecutingAssembly();
            //modelBuilder.Configurations.AddFromAssembly(CurrentAssmbly);

            var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists<MFContext>(modelBuilder);
            Database.SetInitializer(sqliteConnectionInitializer);
        }
    }
}
